package addon.w3.mdx.com;

import java.io.IOException;

import addon.w3.mdx.MDXCOM;
import addon.w3.mdx.LEDataInputStream;
import addon.w3.mdx.MDXException;

/**
 * GLBS						// [GlobalSequences]
	long	nbytes;
	long	durations[ndurs];		// ndurs = nbytes/4;
 * @author madjk
 *
 */
public class MDXGlobalSequenceCOM extends MDXCOM {
	int length = -1;
	int duration[] = null;
	
	public String getTag() {
		return "GLBS";
	}
	
	public void _decode(LEDataInputStream ins) throws IOException, MDXException {
		length = ins.readInt();
		if(length >= 4) {
			duration = new int [length/4];
			for (int i = 0; i < duration.length; i++) {
				duration[i] = ins.readInt();
			}
		}
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("TAG : "+getTag());
		sb.append("\n\tILEN : "+length);
		if(duration != null && duration.length > 0) {
			sb.append("\n\tDURATIONS["+duration.length+"] : ");
			for(int i=0;i<duration.length;i++) {
				sb.append(duration[i]);
				if(i < (duration.length-1)) sb.append(" , ");
			}
		}
		return sb.toString();
	}

	@Override
	public boolean isImplicitTag() {
		// TODO Auto-generated method stub
		return false;
	}
}